package cn.edu.sptc.chensiyi.hellospring.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Controller
@RequestMapping("/data")
public class DataController {
@RequestMapping(method = RequestMethod.GET,value = "/hello")
@ResponseBody
    public String json() {
    return "返回数据是json字符串";
}

@RequestMapping(method = RequestMethod.GET,value = "/html")
    public  String getHTML(Model model){
//    model.addAttribute("name","成龙");

    DateTimeFormatter dateTimeFormatter=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS EEE");
    model.addAttribute("time",dateTimeFormatter.format(LocalDateTime.now()));

    return  "home";
    }
}
